home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 050 / inliner.arc / INLINER.DOC next >
Encoding:
Text File  |  1985-07-25  |  7.9 KB  |  173 lines

  1.                                 Inliner
  2.  
  3.     Version 1.00                                     File: INLINER.PAS
  4. Last revised: 12 Apr 1985                          Author: Anthony M. Marcy
  5.  
  6. DESCRIPTION
  7.  
  8.    Inliner is an assembler which translates 8088 assembly language directly
  9. into Turbo Pascal INLINE code.  It is written in, and generates code for,
  10. Turbo Pascal 2.00 for the IBM PC.  This program is in the public domain.
  11.    Inliner accepts a source language similar, but not identical, to that
  12. of the IBM Macro Assembler (MASM).  It produces a single Turbo INLINE statement
  13. ready to be merged into a Pascal program or used as an Include file.
  14.    All 8088 instructions are supported.  MASM pseudo-ops are not, and there
  15. are a few differences in syntax between Inliner and MASM, as detailed below.
  16.    System requirements are those for running Turbo.  If you can compile
  17. Inliner, you can run it.  (If you can't compile it, you don't need it.)
  18. Maximum assembly program size is set by the size of memory.  Inliner can use
  19. all available contiguous memory.
  20.    The new version 3.00 of Turbo has changes to the INLINE statement which
  21. make it not always compatible with code written for Turbo 2.00.  Inliner 1.00
  22. is designed to work with Turbo 2.00.  In particular, assembly programs which
  23. contain both labels and constant identifiers, and assembled by Inliner, may
  24. not compile correctly under Turbo 3.00.
  25.  
  26. GETTING STARTED
  27.  
  28.    You will be prompted for a source file and a target file.  If no source
  29. filename extension is given, .ASM is assumed.  The default target file is
  30. your source filename with extension .PAS; a carriage return accepts the
  31. default, or you may enter any legal filename.
  32.    Quick trick: entering TRM: as the source file will allow you to type your
  33. input directly into Inliner.  It will not be saved, however, and no editing
  34. is available.  End your input with ctrl-z.  Entering NUL as the target file
  35. will cause no output file to be generated, but you can still see the output
  36. on the screen.  Handy if you just need a line or two, or for testing what
  37. will "work".
  38.    Inliner may also be started from the DOS command line, thus:
  39.                 A> inliner infile.asm outfile.pas
  40. The second parameter may be omitted, in which case the default is assumed.
  41.  
  42.  
  43. INSTRUCTION FORMAT
  44.  
  45.    An Inliner source line takes the general form:
  46.                label: opcode operand, operand ;comment
  47. Each of these components is optional.
  48.  
  49.    A LABEL can be anything that would be legal as a Turbo identifier, limited
  50. in length to a maximum of twenty characters.  The colon is mandatory after
  51. a label.
  52.  
  53.    OPCODEs are the standard Intel mnemonics.  LOCK and the various REP
  54. prefixes are supported.  The segment override prefix can only be placed before
  55. an operand, not before the opcode.
  56.  
  57.    OPERANDs can be of three general kinds: register, address, and immediate.
  58. Register operands are the usual mnemonics - AX,BX, etc.
  59. Address operands have the following form:
  60.                prefix: (type) [base] [index] offset
  61. Each component is optional.  The ordering is strict.
  62.        prefix is a segment override -- DS, CS, SS, or ES
  63.        type is a single letter --  N   Near
  64.                                    F   Far
  65.                                    S   Short
  66.                                    W   Word
  67.                                    B   Byte
  68.        base is a base register -- BX or BP
  69.        index is an index register -- SI or DI
  70.        offset is either a literal constant or a Turbo identifier
  71.  
  72. Turbo identifiers are copied into the INLINE code.  Any identifier which does
  73. not occur as a label is assumed to be a Turbo identifier. The compiler replaces
  74. variable names with their offsets within their segments; it replaces constant
  75. identifiers with their values.  The location counter, *, is also legal.  See
  76. the Turbo manual for details.
  77.      ADD AL,var1     ;var1 is a global variable in the data segment
  78.      ADD AL,[BP]var2 ;var2 is a local variable in the stack segment
  79.      ADD AL,CS:var3  ;var3 is a typed constant in the code segment
  80.  
  81. Immediate operands are distinguished by being prefixed with an equal sign.
  82. They may be constants or Turbo variables.  Thus,
  83.      MOV AX,=2 ;loads the value 2 into AX
  84.      MOV AX,2  ;loads AX with the word at offset 2 in the data segment
  85.      MOV AX,var1  ;loads AX with the contents of variable var1
  86.      MOV AX,=var1 ;loads the offset of variable var1 into AX
  87. The equal sign is optional in the INT, RET, IN, and OUT instructions, and
  88. before character literals.
  89.  
  90.    CONSTANTs can be decimal integers (positive or negative), hex constants
  91. in Turbo format (preceded by $), constant identifers, or character literals
  92. enclosed in single quotes.  Examples:  2   -128   $FF   cons   'x'
  93.    The type must be specified when it cannot otherwise be deduced:
  94.      ADD AX,[BP]2  ;AX - must be a word operand
  95.      INC (W)[BP]2  ;requires (W) or (B)
  96. Immediate numeric constants default to (B)yte if in the range -128..255,
  97. otherwise (W)ord.
  98.  
  99.    JMP requires special treatment.  A (F)ar jump to an absolute address may be
  100. coded with two operands, both immediate constants, representing the segment
  101. and the offset:
  102.      JMP =$0060,=$0100   ;absolute address 0060:0100
  103. A (N)ear jump to an offset in the CS requires a single immediate operand:
  104.      JMP =$0100   ;address CS:0100
  105.      JMP =*-1   ;this instruction jumps to itself
  106. An indirect jump takes either a register or an address operand.  In the latter
  107. case, the type must be specified:
  108.      JMP AX     ;must be (N)ear
  109.      JMP (F)[BP][SI]
  110.      JMP (N)var1
  111. Lastly, the jump target may be an Inliner label.  For forward references,
  112. more efficient code can be generated if (S)hort is specified when possible:
  113.      JMP lab1
  114.      JMP (S)lab2
  115.  
  116.    CALL is similar to JMP, except that (S)hort cannot be used.
  117.  
  118.    The conditional jump instructions -- JE, JNE, etc. -- take a single
  119. operand which may be either an immediate constant in the range -128..127
  120. or an Inliner label.
  121.  
  122.    The string instructions vary slightly from MASM syntax.  REP, REPZ, etc.,
  123. are considered prefixes which must be placed before a string opcode on the
  124. same line.  The special no-operand forms of the string opcodes -- MOVSB,
  125. MOVSW, etc. -- are not implemented.  Instead, use the basic opcode with
  126. a type specifier.  The full two-operand forms may also be written.
  127.      REP CMPS (B)
  128.      REP MOVS (W)[SI],[DI]
  129.  
  130.    Other instructions resemble their counterparts in MASM.  Refer to the
  131. Macro Assembler manual for their formats.  Inliner does not support any
  132. pseudo-ops, such as PROC, END, DW, or ASSUME.  Nor does it support the
  133. 8087 mnemonics.
  134.    Pascal declarations should be used to define data, in place of DB, DW,
  135. EQU, etc.  But remember that your variables are Turbo variables -- Inliner
  136. cannot see your declarations to check type or addressibility.  You must
  137. provide segment overrides where needed.
  138.  
  139.  
  140. EXAMPLES
  141.  
  142.    Here are some more examples of Inliner code:
  143.  
  144.      PUSH BP
  145.  h2: CMP var1,=-1    ;byte variable assumed
  146.      CMP var1,(W)=-1  ;unless overridden
  147.      MOV var2,=var4  ;address is always two bytes
  148.      JE (S)h5
  149.      REPE SCAS(B) ;instead of SCASB
  150.      shl ax,cl   ;lower case is OK
  151.      ESC = 23 , [ DI ] var2 ;spaces are OK, too
  152.      MOV ES:4,'&'
  153.  h5: SUB (W)var3,=$40
  154.      NOP
  155.      CALL (N)xyz ;indirect through variable xyz
  156.                  ;unless xyz is a label
  157.      MOV [BX][DI],CS
  158.      RET (N) 4   ;(N) or (F) required
  159.  
  160.      -----------------------------------------------------------------
  161.  
  162.    Inliner is supported on the RBBS-PC operated by
  163.               James Miles
  164.               "The Programmer's Toolbox"
  165.               (301) 540-7230 (data)
  166.               24 Hrs.
  167. Comments, bug reports, and suggested improvements are encouraged.  Address
  168. them to ANTHONY MARCY or to SYSOP.  If you make extensions or revisions
  169. to this program, please upload so that all may share.
  170.  
  171.                              Enjoy!
  172.  
  173.